package com.etc.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/*这是一个控制器*/
@Controller
public class HelloController {

	@RequestMapping(value = "hello")
	public String sayHello(HttpServletRequest request) {
		request.setAttribute("name", "kitty");
		return "hello"; // 返回一个视图名字,转发到/web-inf/jsp/hello.jsp
	}
	
	
	@RequestMapping(value = "hello3")
	public String sayHello3(Model model) {
		model.addAttribute("name", "kitty3");
		return "hello"; // 返回一个视图名字,转发到/web-inf/jsp/hello.jsp
	}
	
	@RequestMapping(value = "hello2")
	public String sayHello2(String name,HttpServletRequest request) {
		request.setAttribute("name", name);
		return "hello"; // 返回一个视图名字,转发到/web-inf/jsp/hello.jsp
	}
	
	@RequestMapping(value = "index")
	public String redirectform() {
		return "form"; // 返回一个视图名字,转发到/web-inf/jsp/hello.jsp
	}

}
